﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;

namespace MyTime
{
    public partial class MainForm : Form
    {
        private Settings _settings;
        private Core.Entities.TimeTracker _timeTracker;
        public MainForm()
        {
            InitializeComponent();
            _timeTracker = new Core.Entities.TimeTracker(Application.ExecutablePath);
            _settings = new Settings(_timeTracker);
            _timeTracker.TimeToReport += (sender, e) =>
            {
                this.Show();
            };
            this.Hide();
        }
        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Return)
            {
                if (submissionTxtBox.Text.Length == 0)
                    return;
                _timeTracker.ReportTime(submissionTxtBox.Text, DateTime.Now);
                this.Hide();
            }
        }
        private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            _settings.ShowDialog();
            //popUpTimer.Start(); ???
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }

        private void summaryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Summary s = new Summary(_timeTracker.GetTime());
            s.Show();
        }

        private void pauseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (pauseToolStripMenuItem.Checked)
            {
                _timeTracker.StartTimer();
                //popUpTimer.Start();
                pauseToolStripMenuItem.Checked = false;
            }
            else
            {
                //popUpTimer.Stop();
                _timeTracker.StopTimer();
                pauseToolStripMenuItem.Checked = true;
            }
        }
        private void reportNowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Show();
        }
    }
}
